<div class="container-fluid">
    <div class="block-header">
        <h2>语言 > 添加新语言 & Key</h2>
    </div>
    <!-- Vertical Layout -->
    <div class="row">
        <div class="col-lg-6 col-md-6">
            <div class="card">
                <div class="header">
                    <h2>添加新语言</h2>
                </div>
                <div class="body">
                    <div class="alert alert-success email-settings-alert"></div>
                    <form class="email-settings" method="POST">
                        <div class="form-group form-float">
                            <div class="form-line">
                                <input type="text" id="lang" name="lang" class="form-control">
                                <label class="form-label">语言名称 <small>仅可以使用英文字母，不允许使用空格。 例如：TaiWan</small></label>
                            </div>
                        </div>
                        <div>注意：这可能需要5分钟.</div>
                        <input type="hidden" name="hash_id" value="<?php echo Wo_CreateSession();?>">
                        <button type="submit" class="btn btn-primary m-t-15 waves-effect">添加新语言</button>
                    </form>
                </div>
            </div>
        </div>
        <div class="col-lg-6 col-md-6">
            <div class="card">
                <div class="header">
                    <h2>添加新 Key</h2>
                </div>
                <div class="body">
                    <div class="alert alert-success key-settings-alert"></div>
                    <form class="key-settings" method="POST">
                        <div class="form-group form-float">
                            <div class="form-line">
                                <input type="text" id="lang_key" name="lang_key" class="form-control">
                                <label class="form-label">Key 名称 <small>仅可以使用英文字母，不允许使用空格，例如：this_is_a_key</small></label>
                            </div>
                        </div>
                        <input type="hidden" name="hash_id" value="<?php echo Wo_CreateSession();?>">
                        <button type="submit" class="btn btn-primary m-t-15 waves-effect">添加 Key</button>
                    </form>
                </div>
            </div>
        </div>
        <div class="clearfix"></div>
    </div>
    <!-- #END# Vertical Layout -->
<script>

$(function() {
    var form_email_settings = $('form.email-settings');
    form_email_settings.ajaxForm({
        url: Wo_Ajax_Requests_File() + '?f=admin_setting&s=add_new_lang',
        beforeSend: function() {
            form_email_settings.find('button').text('请稍后..');
        },
        success: function(data) {
            if (data.status == 200) {
                $("html, body").animate({ scrollTop: 0 }, "slow");
                $('.email-settings-alert').html('<i class="fa fa-check"></i> 语言添加成功');
                setTimeout(function () {
		            window.location.href = '<?php echo Wo_LoadAdminLinkSettings('manage-languages'); ?>';
		        }, 1000);
            }
            form_email_settings.find('button').text('添加语言');
        }
    });

    var form_key_settings = $('form.key-settings');
    form_key_settings.ajaxForm({
        url: Wo_Ajax_Requests_File() + '?f=admin_setting&s=add_new_lang_key',
        beforeSend: function() {
            form_key_settings.find('button').text('请稍后..');
        },
        success: function(data) {
            if (data.status == 200) {
                $("html, body").animate({ scrollTop: 0 }, "slow");
                $('.key-settings-alert').html('<i class="fa fa-check"></i> Key成功添加');
                 setTimeout(function () {
                    window.location.href = data.url;
                  }, 1000);
            } else {
                alert(data.message);
            }
            form_key_settings.find('button').text('添加Key');
        }
    });
});
</script>